<!DOCTYPE html>
<html lang="zh">

	<head>
		<meta name="renderer" content="webkit" />
		<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" />
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link rel="stylesheet" href="https://unpkg.com/mint-ui/lib/style.css">
		<link rel="stylesheet" href="less/contract.css">
		<script src="https://unpkg.com/vue/dist/vue.js"></script>
		<script src="https://unpkg.com/mint-ui/lib/index.js"></script>
		<script type="text/javascript" src="./lib/charting_library/charting_library.min.js"></script>
		<script type="text/javascript" src="./lib/datafeeds/udf/dist/polyfills.js"></script>
		<script type="text/javascript" src="./lib/datafeeds/udf/dist/bundle.js"></script>
		<script src="./lib/jquery.js"></script>
		<script src="./lib/echarts.min.js"></script>
		<script type="text/javascript" src="./lib/datafeeds/datafeed.js"></script>
		<script src="./lib/hammer.min.js"></script>
		<script type="text/javascript">
			function getParameterByName(name) {
				name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
				var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
					results = regex.exec(location.search);
				return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
			}
			var setStudy, unsetStudy, MACDEntityId, Wwidget;
			var datafeed = datafeed

			TradingView.onready(function() { //初始化tradinview
				var widget = window.tvWidget = new TradingView.widget({
					fullscreen: false,
					header_indicators: false,
					adaptive_logo: false,
					symbol: 'BTC/USDT', //币种名称
					interval: '5', //默认显示规则
					https: false,
					width: '100%',
					container_id: "tv_chart_container", //`id`属性为指定要包含widget的DOM元素id。
					// fullscreen: true,  //布尔值显示图表是否占用窗口中所有可用的空间。
					toolbar_bg: '#152335', //背景色
					height: getParameterByName('height') / 1.9,
					//	BEWARE: no trailing slash is expected in feed URL
					datafeed: datafeed,
					library_path: "./lib/charting_library/",
					locale: getParameterByName('lang') || "zh",
					preset: "mobile",
					disabled_features: [ //开启图表功能的字符串文字允许将用户设置保存到本地存储
						"use_localstorage_for_settings",
						"border_around_the_chart",
						'volume_force_overlay', //防止他们重叠
						'widget_logo' //去掉Logo
					],
					overrides: {
						"symbolWatermarkProperties.transparency": 90,
						"paneProperties.legendProperties.showStudyTitles": false,
						"paneProperties.legendProperties.showStudyArguments": false,
						"paneProperties.legendProperties.showStudyValues": false,
						// 边框
						"mainSeriesProperties.candleStyle.drawBorder": false,
						// 坐标轴和刻度标签颜色
						// "scalesProperties.lineColor": "#101928",
						"header_indicators": false,
						"paneProperties.background": "#152335", //画布背景颜色
						"paneProperties.vertGridProperties.color": "#18263A", //网格线
						"paneProperties.horzGridProperties.color": "#18263A",
						"scalesProperties.lineColor": "#18263A",
					},

				});
				widget.onChartReady(function() {
					widget.chart().setResolution('5');
					widget.chart().setChartType(1);
					widget.MALine5 = widget.chart().createStudy('Moving Average', false, false, [5], null, {
						'Plot.color': '#5E53C6'
					});
					widget.MALine10 = widget.chart().createStudy('Moving Average', false, false, [10], null, {
						'Plot.color': '#7cacc2'
					});
					widget.MALine30 = widget.chart().createStudy('Moving Average', false, false, [30], null, {
						'Plot.color': '#45B765'
					});
					widget.MALine60 = widget.chart().createStudy('Moving Average', false, false, [60], null, {
						'Plot.color': '#B7225E'
					});
					var timeList = ['time', '1min', '5min', '15min', '30min', '60min', '1day']
					var times = ['1', '1', '5', '15', '30', '60', 'D']
					timeList.forEach(function(v, i) {
						var button = widget.createButton();
						button.attr('title', v)
						button.append($('<span>' + v + '</span>'))
						button.on('click', function(a) {
							if (v === 'time') {
								$($(a)[0].target).parents().siblings().find('.red').removeClass('red')
								$($(a)[0].target).addClass('red')
								widget.chart().setChartType(3)
							} else {
								widget.chart().setResolution(times[i], function() {
									$($(a)[0].target).parents().siblings().find('.red').removeClass('red')
									$($(a)[0].target).addClass('red')
									widget.chart().setChartType(1)
								})
							}
						})
					})
				});
			})
		</script>
		<title></title>
	</head>
	<body>
		<div id="contract">
			<div id="tv_chart_container"></div>
		</div>
	</body>
	<script type="text/javascript">
		var contract = new Vue({
			el: '#contract',
			data: {

			},
			methods: {

			}

		})
	</script>

</html>
